/*
 *  ABinViewSetting.cpp
 *  libavid
 *
 *  Created by Peter on 23.02.12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */
#include "ABinViewSetting.h"
#include "AStream.h"

A_IMPLEMENT_CLASS( 'BVst', ABinViewSetting, ASetting );

void ABinViewSetting::clear()
{
	TR_NOT_IMPLEMENTED();
}

void ABinViewSetting::readFromStream( AStream& str, const AObjDoc& objd )
{
	clear();
	
	ASetting::readFromStream( str, objd );
	
	UInt8 tagMarker;
	UInt8 version;
	
	str.readPod( tagMarker );
	str.readPod( version );
	
	TR_ASSERT( tagMarker == 0x02 );
	TR_ASSERT( version == 10 );
	
	UInt16 numColumns;
	str.readPod( numColumns );
	
	for( int i = 0; i < numColumns; ++i )
	{
		Column* col = new Column;
		
		col->readFromStream( str );
		_columns.push_back( col );
	}
	
	UInt8 endTagMark;
	str.readPod( endTagMark );
	TR_ASSERT( endTagMark == 0x03 );
}

void ABinViewSetting::Column::readFromStream( AStream& str )
{
	_columnTitle = str.readString();
	str.readPod( _columnFormat );
	str.readPod( _columnType );
	_columnHidden = str.readBool();
}

void ABinViewSetting::dump( std::ostream& str ) const
{
	str << "ABinViewSetting {" << std::endl;
	
	// Base class
	ASetting::dump( str );
	
	str << "\t_columns[ " << _columns.size() << " ] {" << std::endl;
	
	ColumnList::const_iterator it = _columns.begin();
	int i = 0;
	
	for( ; it != _columns.end(); ++it, ++i ){
		str << "\t\tColumn #" << i << " { " << std::endl;
		
		str << "\t\t\t_columnTitle: \"" << (*it)->_columnTitle << "\"" << std::endl;
		str << "\t\t\t_columnFormat: " << (*it)->_columnFormat << std::endl;
		str << "\t\t\t_columnType: " << (*it)->_columnType << std::endl;
		str << "\t\t\t_columnHidden: " << (*it)->_columnHidden << std::endl;
		
		str << "\t\t}" << std::endl;
	}
	
	str << "}" << std::endl;
}